package com.platform.comm.entity;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;


/**
 * Description: 实体类
 * <p>使用@CreateBy,@CreateDate等需要开启JPA审计功能: @EnableJpaAuditing</p>
 * @author libin
 * Created on 2019/4/18
 **/
@EntityListeners(AuditingEntityListener.class)
@EqualsAndHashCode(callSuper = true)
@MappedSuperclass
public class BaseEntity extends IdEntity {

    private static final long serialVersionUID = 5168548128261382582L;

    /**
     * 创建时间
     */
    @Getter
    @Setter
    @CreatedDate
    @Column(name = "create_date", nullable = false, updatable = false)
    private LocalDateTime createDate;


    /**
     * 修改时间
     */
    @Getter
    @Setter
    @LastModifiedDate
    @Column(name = "update_date")
    private LocalDateTime updateDate;

    public BaseEntity() {
    }

    public BaseEntity(String id) {
        this.setId(id);
    }
}
